package ch.ethz.group3.myalbum.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.util.SC;

public class GroupsDataSource extends DataSource {

	private static GroupsDataSource instance = null;

	public GroupsDataSource(String id) {
		setID(id);
		DataSourceTextField groupId = new DataSourceTextField("groupId");
		groupId.setPrimaryKey(true);
		groupId.setHidden(true);

		DataSourceTextField thumbnail = new DataSourceTextField("thumbnail");
		DataSourceTextField name = new DataSourceTextField("name");
		DataSourceIntegerField members = new DataSourceIntegerField("members");
		DataSourceIntegerField pictures = new DataSourceIntegerField("pictures");

		setFields(groupId, thumbnail, name, members, pictures);
		setClientOnly(true);
	}

	public static GroupsDataSource getInstance() {
		if (instance == null) {
			instance = new GroupsDataSource(SC.generateID());
		}
		return instance;
	}
}
